package com.editor.smsmanager;

import android.content.Context;
import android.util.AttributeSet;

import com.editor.smsmanager.utils.MyLog;

import org.webrtc.SurfaceViewRenderer;
import org.webrtc.VideoFrame;

public class WebrtcRenderer extends SurfaceViewRenderer {

    public interface FirstFrameListener{
        void onFirstFrame();
    }

    FirstFrameListener firstFrameListener;

    public WebrtcRenderer(Context context) {
        super(context);
    }

    public WebrtcRenderer(Context context, AttributeSet attrs) {
        super(context, attrs);
    }

    @Override
    public void onFrame(VideoFrame frame) {
        super.onFrame(frame);

        MyLog.D("WebrtcRenderer","onFrame time="+frame.getTimestampNs());
    }

    @Override
    public void onFirstFrameRendered() {
        super.onFirstFrameRendered();
        if(firstFrameListener != null) firstFrameListener.onFirstFrame();
    }

    public void setFirstFrameListener(FirstFrameListener firstFrameListener) {
        this.firstFrameListener = firstFrameListener;
    }
}
